<template>
	<view>
		<view class="bg-gradual-blue text-center" style="line-height: 100upx;font-size: 32upx;width: 100%;position: fixed;top: 0;z-index: 999;">{{title}}</view>
		<view style="margin-top: 100upx;">
			<view v-for="(item,index) in list" :key="index" class="margin-lr-xl padding-tb-xl flex justify-between solid-bottom" @click="ToBook(item._id)">
				<view style="width: 18%;">
					<image :src="item.cover" mode="widthFix" class="shadow" style="height: 160upx;"></image>
				</view>
				<view style="width: 77%;">
					<view class="text-bold text-lg" style="line-height: 60upx;">{{item.title}}</view>
					<view class="text-sm text-gray" style="line-height: 50upx;">{{item.author}} · {{item.majorCate}} · {{parseInt(item.wordCount/10000)}}万字</view>
					<view class="text-sm text-gray text-cut" style="line-height: 50upx;">{{item.lastChapter}}</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	var that;
	var id;
	var totle;
	export default {
		data() {
			return {
				list : [],
				page : 1,
				op : true,
				title:null
			}
		},
		
		onLoad(option) {
			that = this
			id = option.id
			that.title = option.title
			that.util.request({
				'url' : 'VueConList',
				'data' : {
					id : option.id,
					page : that.page
				},
				success:function(res){
					that.list = res.data.data.list
					totle = res.data.data.tot
				}
			})
		},
		
		onReachBottom() {
			that = this
			that.page++
			if (that.page > totle) {
				return false
			} else{
				that.moreList()
			}
		},
		
		methods: {
			ToBook(e){
				uni.navigateTo({
					url: '/pages/book/book?id='+e
				});
			},
			
			moreList() {
				that.util.request({
					'url' : 'VueConList',
					'data' : {
						id : id,
						page : that.page
					},
					success:function(res){
						var data = res.data.data.list
						var n_list = JSON.stringify(data).substr(1, JSON.stringify(data).length-1)
						var o_list = JSON.stringify(that.list).substr(0, JSON.stringify(that.list).length - 1)
						var newdata = o_list+','+n_list
						var list = JSON.parse(newdata)
						that.list = list
					},
				})
			},
		}
	}
</script>

<style>
page{background-color:#ffffff;}
</style>
